
import { http } from '@/utils/http'
import { AppThunk } from '../index'
import { setInfo } from '../modules/user'

// 3. 异步action
export const getUserAction = (payload?: unknown): AppThunk => {
  return async (dispatch, getState) => {
    const res = await http.get('/user/profile', {
      headers: {
        Authorization: `Bearer ${getState().LoginStore.token}`
      }
    })
    console.log(res.data.data)
    dispatch(setInfo(res.data.data))
  }
}